﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Template.Master" Inherits="System.Web.Mvc.ViewPage<JLL.China.Web.Areas.Listings.Models.ListingFloorPlanModel>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <div id="page-heading">
        <a class="icons icon-circle-arrow-right"></a><b><span class="show-listing">
        <%=ViewData["HeadingMsgStep6"].ToString()%></span></b>
    </div>
    <div class="menu-nav">
        <% Html.RenderPartial("TopMenu");%>
    </div>
    <!-- end page-heading -->
    <table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
        <tr>
            <th rowspan="3" class="sized">
                <img src="<%=Url.Content("~/Content/images/shared/side_shadowleft.jpg")%>" width="20"
                    height="300" alt="" />
            </th>
            <th class="topleft">
            </th>
            <td id="tbl-border-top">
                &nbsp;
            </td>
            <th class="topright">
            </th>
            <th rowspan="3" class="sized">
                <img src="<%=Url.Content("~/Content/images/shared/side_shadowright.jpg")%>" width="20"
                    height="300" alt="" />
            </th>
        </tr>
        <tr>
            <td id="tbl-border-left">
            </td>
            <td class="content-table-inner">
                <!--  start content-table-inner ...................................................................... START -->
                <div id="content-table-inner">
                    <!--  start message-blue -->
                    <% Html.RenderPartial("Measage");%>
                    <!--  end message-blue -->
                    <!--  start step-holder -->
                    <%Html.RenderPartial("StepHolder", (ViewData["ListingID"] != null) ? ViewData["ListingID"].ToString() : null); %>
                    <!--  end step-holder -->
                    <!----BEGIN WINDOW BOX ----->
                    <a id="quickprojectposting" data-fancybox-type="iframe" href="<%=Url.Content("~/")+ViewData["now_controller"].ToString()%>/Step7">
                    </a>
                    <!----END WINDOW BOX ----->
                    <%-- <form id="mainform" class="list_item_form" method="post">--%>
                    <% using (Html.BeginForm("Step6", ViewData["ActionPost"].ToString(), FormMethod.Post, new { id = "mainform", enctype = "multipart/form-data", @class = "list_item_form" }))
                       { %>
                    <%--<input type="hidden" name="CategoryID" value="<%=ViewData["CategoryID"].ToString()%>" />
        <input type="hidden" name="NewsContentID" value="<%=(this.Model!=null)?(this.Model.ID!=null)?this.Model.ID.ToString():"0":"0"%>" />      	--%>
                    <% = Html.HiddenFor(x => x.ListingFloorPlan.ListingFloorPlan_ID) %>
                    <% = Html.HiddenFor(x => x.ListingFloorPlan.ListingFID) %>
                    <table border="0" cellpadding="0" cellspacing="0" class="tbl-shortform">
                        <tr>
                            <td>
                                <b>Type of Floor Plan</b>
                            </td>
                            <td>
                            </td>
                        </tr>
                        <tr>
                            <th style="min-width: 100px">
                                <br />
                                <b>Type/model</b><br />
                                <br />
                                <%--<input type="text" name="type-model" class="inp-form validate[required]"/>--%>
                                <%= Html.TextBoxFor(m => m.ListingFloorPlan.TypeModel, new { id = "typemodel", name = "typemodel", @class = "inp-form validate[required]" })%>
                            </th>
                            <th>
                                <br />
                                <b>No of units</b><br />
                                <br />
                                <%-- <input type="text" name="type-model" class="inp-form validate[required]" />--%>
                                <%= Html.TextBoxFor(m => m.ListingFloorPlan.NoUnit, new { id = "nounit", name = "nounit", @class = "inp-form validate[required,custom[number]]" })%>
                            </th>
                            <th style="padding-left: 5px" id="">
                                <br />
                                <b>Floor plan image</b><br />
                                <br />

                                <script>
                                    function checkFileExtension(elem) {
                                        var filePath = elem.value;


                                        if (filePath.indexOf('.') == -1)
                                            return false;


                                        var validExtensions = new Array();
                                        var ext = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase();


                                        validExtensions[0] = 'jpg';
                                        validExtensions[1] = 'jpeg';
                                        validExtensions[2] = 'bmp';
                                        validExtensions[3] = 'png';
                                        validExtensions[4] = 'gif';



                                        for (var i = 0; i < validExtensions.length; i++) {
                                            if (ext == validExtensions[i])
                                                return true;
                                        }


                                        alert('The file extension ' + ext.toUpperCase() + ' is not allowed!');
                                        $('#inputfile').empty();
                                        $('#inputfile').html('<input type="file" onchange="checkFileExtension(this);" name="floorImg" id="floorImg" class="inp-form validate[required]" />');
                                        return false;
                                    }
</script>
                                <div id="inputfile">
                                <% string requireclass = "inp-form validate[required]";
                                    if (this.Model.ListingFloorPlan != null)
                                   {
                                       requireclass = "inp-form";
                                   } %>
                                <input type="file" onchange="checkFileExtension(this);" name="floorImg" id="floorImg"
                                    class="<%=requireclass %>" />
                                    </div>
                            </th>
                        </tr>
                        <tr>
                            <th style="min-width: 100px">
                                <br />
                                <b>Type/model (Local)</b><br />
                                <br />
                                <%--                                <input type="text" name="type-model" class="inp-form validate[required]"/>--%>
                                <%= Html.TextBoxFor(m => m.ListingFloorPlan_Local.TypeModel, new { id = "typemodel_local", name = "typemodel_local", @class = "inp-form validate[required]" })%>
                            </th>
                            <th>
                            </th>
                            <td align="right">
                                <%if (Model.ListingFloorPlan != null)
                                  { %>
                                <input type="submit" value="Update" class="buttons" style="float: right; margin-right: 8px;" />
                                <%}
                                  else
                                  {%>
                                <input type="submit" value="Add" class="buttons" style="float: right; margin-right: 8px;" />
                                <%}%>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <br />
                                <br />
                            </td>
                        </tr>
                    </table>
                    <%--                    </form>--%>
                    <%} %>
                    <%
                        if (ViewData["ProjectFloor"] != null)
                        {
                            var list = ViewData["ProjectFloor"] as IList<JLL.China.Model.ListingFloorPlan>;

                            if (list.Count > 0)
                            {
                                
                    %>
                    <div>
                        <ul id="listfloorplan-root">
                            <%foreach (var item in list)
                              {%>
                            <li>
                                <ul class="listfloorplan">
                                    <li style="width: 18%;"><b>Type/model</b><br />
                                        <br />
                                        <label>
                                            <%=item.TypeModel %></label></li>
                                    <li><b>Floor plan image</b><br />
                                        <br />
                                        <% var imgval = "data:image/png;base64," + Convert.ToBase64String((byte[])item.FloorPlanImg.ToArray());%>
                                        <img style="max-height: 120px; max-width: 160px;height:120px;" src="<%=imgval%>" /></li>
                                    <li><b>No of units</b><br />
                                        <br />
                                        <input type="text" disabled="disabled" value="<%=item.NoUnit %>" />
                                    </li>
                                    <li><b></b>
                                        <br />
                                        <br />
                                        <a>
                                            <input type="button" value="Edit" class="buttons" style="margin-right: 0; float: none;
                                                width: 68px; cursor: pointer" onclick="window.location.href='<%=Url.Content("~/" + ViewData["now_controller"].ToString() + "Step6/" + item.ListingFID.ToString() + "?listingFloorPlan_ID=" + item.ListingFloorPlan_ID)%>'" /></a>
                                        <%--                                             <%= Html.ActionLink("Edit ", "Step6", new { id = item.ListingFID, prjDirFloorPlan_ID = item.ProjectDirFloorPlan_ID }, new { @title = "View / Edit", @class = "buttons",style="width: 68px;" })%>
                   --%><%-- <%= Html.ActionLink(" ", "Delete", new { id = item.Event_ID }, new { @title = "Delete", @class = "icon-2 info-tooltip remove-btn" })%> 
                    <%= Html.ActionLink(" ", "ChangeStatus", new { id = item.Event_ID,status = item.Status, Language = item.LanguageFID,orderby = "", descending = "" }, new { @title = "Change Status", @class = "icon-3 info-tooltip" })%>--%>
                                    </li>
                                    <br />
                                    <br />
                                    <a class="remove-btn" href="<%=Url.Content("~/" + ViewData["now_controller"].ToString() + "DeleteStep6/" +item.ListingFloorPlan_ID)%>">
                                        <input type="button" value="Remove" class="buttons icon-2 info-tooltip " style="margin-right: 0;
                                            float: none; cursor: pointer" /></a>
                                </ul>
                            </li>
                            <%} %>
                        </ul>
                    </div>
                    <% }
                        } %>
                </div>
                <!--  end table-content  -->
            </td>
            <td id="tbl-border-right">
            </td>
        </tr>
        <tr>
            <th class="sized bottomleft">
            </th>
            <td id="tbl-border-bottom">
                &nbsp;
            </td>
            <th class="sized bottomright">
            </th>
        </tr>
    </table>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="CSS" runat="server">
    <link href="<%=Url.Content("~/Scripts/qtip2/jquery.qtip.min.css") %>" rel="stylesheet"
        type="text/css" />
    <link href="<%=Url.Content("~/Scripts/uploadify/uploadify.css") %>" rel="stylesheet"
        type="text/css" />
    <link href="<%=Url.Content("~/Content/css/mod-listing.css") %>" rel="stylesheet"
        type="text/css" />
    <link href="<%=Url.Content("~/Scripts/jquery.validation/validationEngine.jquery.css")%>"
        rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="JS" runat="server">

    <script src="<%=Url.Content("~/Scripts/knockout/knockout.js")%>" type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/knockout/knockout.mapping.js")%>" type="text/javascript"></script>

    <script type="text/javascript" src="<%= Url.Content("~/Scripts/uploadify/swfobject.js") %>"></script>

    <script type="text/javascript" src="<%= Url.Content("~/Scripts/uploadify/jquery.uploadify.min.js")  %>"></script>

    <script src="<%=Url.Content("~/Scripts/qtip2/jquery.qtip.min.js")%>" type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/jquery.validation/jquery.validationEngine-en.js")%>"
        type="text/javascript"></script>

    <script src="<%=Url.Content("~/Scripts/jquery.validation/jquery.validationEngine.js")%>"
        type="text/javascript"></script>

   
    <script type="text/javascript">
       
        $(document).ready(function() {
            function dialogue(content, title) {
                /* 
                * Since the dialogue isn't really a tooltip as such, we'll use a dummy
                * out-of-DOM element as our target instead of an actual element like document.body
                */
                $('<div />').qtip(
                    {
                        content: {
                            text: content,
                            title: title
                        },
                        position: {
                            my: 'center', at: 'center', // Center it...
                            target: $(window) // ... in the window
                        },
                        show: {
                            ready: true, // Show it straight away
                            modal: {
                                on: true, // Make it modal (darken the rest of the page)...
                                blur: false // ... but don't close the tooltip when clicked
                            }
                        },
                        hide: false, // We'll hide it maunally so disable hide events
                        style: 'qtip-light qtip-rounded qtip-dialogue', // Add a few styles
                        events: {
                            // Hide the tooltip when any buttons in the dialogue are clicked
                            render: function(event, api) {
                                $('button', api.elements.content).click(api.hide);
                            },
                            // Destroy the tooltip once it's hidden as we no longer need it!
                            hide: function(event, api) { api.destroy(); }
                        }
                    });
            }
            //



            function Confirm(question, callback) {
                // Content will consist of the question and ok/cancel buttons
                var message = $('<p />', { text: question }),
                    cancel = $('<button />', {
                        text: 'Yes',
                        click: function() { callback(true); }
                    }),
                    ok = $('<button />', {
                        text: 'No',
                        click: function() { callback(false); }
                    })
                    ;

                dialogue(message.add(ok).add(cancel), 'Confirm');
            };
            /*
            Confirm("Do you like to post the project listing now?", function(yes) {
            if (yes) {
            //fancybox
            $("#quickprojectposting").fancybox({
            maxWidth: 800,
            maxHeight: 800,
            fitToView: false,
            width: '38%',
            height: '60%',
            autoSize: false,
            closeClick: false,
            openEffect: 'none',
            closeEffect: 'none'
            }).trigger("click");

                }

            });*/
            //prompt for delete button
            $('.remove-btn').click(function(e) {
                e.preventDefault(); //prevent default action for anchor
                var self = this;
                Confirm("Confirm removed the selected records?", function(yes) {
                    if (yes) {
                        $("#content-outer").showLoading();
                        window.location = self.href;
                    }


                });

            });
            //
            jQuery("#mainform").validationEngine({
                prettySelect: true,
                useSuffix: "_chzn",
                promptPosition: "topLeft",
                scroll:false
            });
        });
    </script>

</asp:Content>
